package com.fz.mapper;

import com.fz.entity.Book;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by ZCY on 2018-01-17.
 */
public interface BookMapper {
    /*查询商品*/
    @Select("select * from book")
   public List<Book> query();
    /*添加商品*/
    @Insert("insert into book values(null,#{name},#{author},#{price},#{ctime},#{flag},#{intro})")
    public int insert(Book book);
    /*指定的添加商品*/
    @Insert("insert into book(name,author,price,ctime) values(#{name},#{author},#{price},#{ctime})")
    public int add(@Param("name") String name, @Param("author") String author, @Param("price") double price, @Param("ctime")Date ctime);
   /*使用MaP添加数据*/
   @Insert("insert into book(name,author,price,ctime) values(#{name},#{author},#{price},#{ctime})")
   public  int save(Map<String,Object> values);
  /*查询所有的表名*/
  @Select("show tables")
  public String[] querytables();
  /*数据的删除一条*/
  @Delete("delete from book where id=#{id}")
  public int deletaById(int bookid);
  /*根据商品的名字进行-模糊-删除数据*/
  @Delete("deleta from book where name like #{name}")
  public  int deleteName(String name);

  /*查询数据一条数据*/
  @Select("select * from book where id=#{id}")
  public  Book queryId(int id);
  /*数据的修改*/
  @Update("update book set name=#{name},author=#{author},price=#{price},ctime=#{ctime}where id=#{id}")
  public int update(Book book);
    /*根据商品的id改价格*/
    @Update("update book set price=#{price} where id=#{id}")
   public int updatebid(@Param("id") int id, @Param("price") double price );




}
